package cn.thinkluck.pattern.strategy;

/**
 * 计算器
 *
 * @Author liutao
 * @DateTime 2024/8/1 下午10:18
 */
public class Calculator {
    //持有一个算法策略
    private final Operation operation;

    public Calculator(Operation operation) {
        this.operation = operation;
    }

    /**
     * 执行计算
     *
     * @param num1
     * @param num2
     * @return
     */
    public double calculate(double num1, double num2) {
        return operation.execute(num1, num2);
    }
}
